package com.edu.exam.enums.curriculum.teaching;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 调整类型枚举
 *
 * 班级调整的类型定义
 *
 * @author System
 * @version 1.0.0
 */
public enum AdjustmentType implements BaseEnum {
    MERGE("MERGE", "班级合并"),
    SPLIT("SPLIT", "班级拆分"),
    STUDENT_ADJUSTMENT("STUDENT_ADJUSTMENT", "学生调班");

    private final String code;
    private final String description;

    AdjustmentType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static AdjustmentType fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("AdjustmentType code cannot be null or empty");
        }
        for (AdjustmentType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown adjustment type code: " + code);
    }

    public static AdjustmentType fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            throw new IllegalArgumentException("AdjustmentType description cannot be null or empty");
        }
        for (AdjustmentType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown adjustment type description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}